# arr = [0] * 100
# for student in range(1, len(arr) + 1):
#     #第一个学生
#     if student == 1:
#         for i in range(student - 1, len(arr)):
#             arr[i] ^= 1
#     #第二个学生
#     elif student == 2:
#         for i in range(student - 1, len(arr)):
#             arr[i] ^= 1
#     #其他学生
#     else:
#         for i in range(student - 1, len(arr), student):
#             arr[i] ^= 1

# for i in range(len(arr)):
#     if arr[i] == 1:
#         print(i + 1, end = " ")
        

# arr = [0] * 100

# for student in range(1, len(arr) + 1):
#     #第一个学生
#     if student == 1:
#         for i in range(student - 1, len(arr)):
#             arr[i] ^= 1
#     #第二个学生
#     elif student == 2:
#         for i in range(student - 1, len(arr)):
#             arr[i] ^= 1
#     #其他学生
#     else:
#         for i in range(student -1, len(arr), student):
#             arr[i] ^= 1
    
# for i in range(len(arr)):
#     if arr[i] == 1:
#         print(i + 1, end = " ")

# def solve(matrix):
#     top, bottom = 0, len(matrix) - 1
#     left, right = 0, len(matrix[0]) - 1
#     arr = []
#     while left <= right and top <= bottom:
#         #向右
#         for i in range(left, right + 1):
#             arr.append(matrix[left][i])
#         top += 1
#         #向下
#         for i in range(top, bottom + 1):
#             arr.append(matrix[i][right])
#         right -= 1
#         #如果还有行就向左
#         if top <= bottom:
#             for i in range(right, left - 1, -1):
#                 arr.append(matrix[bottom][i])
#             bottom -= 1
#         #如果还有行就像上
#         if left <= right:
#             for i in range(bottom, top - 1, -1):
#                 arr.append(matrix[i][left])
#             left += 1
#     return arr




# row, col = map(int, input().split(" "))
# matrix = []
# for i in range(row):
#     rows = list(map(int, input().split(" ")))
#     matrix.append(rows)

# arr = solve(matrix)
# print(arr)




# def solve(matrix):
#     top, bottom = 0, len(matrix) - 1
#     left, right = 0, len(matrix[0]) - 1
#     arr = []
#     while left <= right and top <= bottom:
#         #向右
#         for i in range(left, right + 1):
#             arr.append(matrix[top][i])
#         top += 1
#         #向下
#         for i in range(top, bottom + 1):
#             arr.append(matrix[i][right])
#         right -= 1
#         #如果还有行就向左
#         if top <= bottom:
#             for i in range(right, left - 1, -1):
#                 arr.append(matrix[bottom][i])
#         bottom -= 1
#         #如果还有列就向上
#         if left <= right:
#             for i in range(bottom, top - 1, -1):
#                 arr.append(matrix[i][left])
#         left += 1
#     return arr
        



# row, col = map(int, input().split(" "))
# matrix = []
# for i in range(row):
#     rows = list(map(int, input().split(" ")))
#     matrix.append(rows)

# print(solve(matrix))




# n = int(input())
# arr = list(map(int, input().split(" ")))
# max_length =  1
# cur_length = 1
# for i in range(len(arr) - 1):
#     if arr[i] < arr[i + 1]:
#         cur_length += 1
#         if cur_length > max_length:
#             max_length = cur_length
#     else:
#         cur_length = 1
# print(max_length)



# n = int(input())
# arr = list(map(int, input().split(" ")))
# max_length = 1
# cur_length = 1
# for i in range(1, len(arr)):
#     if arr[i - 1] < arr[i]:
#         cur_length += 1
#         if cur_length > max_length:
#             max_length = cur_length
#     else:
#         cur_length = 1
# print(max_length)


#盛水最多的容器

# n = int(input())
# arr = list(map(int, input().split(" ")))
# max_s = -1
# for i in range(len(arr) - 1):
#     for j in range(i + 1, len(arr)):
#         cur_s = (j - i) * min(arr[i], arr[j])
#         if cur_s > max_s:
#             max_s = cur_s
        
# print(max_s)

#思路2
#(right - left) * min(arr[left], arr[right])
n = int(input())
arr = list(map(int, input().split(" ")))
left = 0
right = len(arr) - 1
max_s = -1
while left < right:
    cur_s = (right - left) * min(arr[left], arr[right])
    if cur_s > max_s:
        max_s = cur_s
    if arr[left] > arr[right]:
        right -= 1
    else:
        left += 1

print(max_s)














































